package com.chixing.util;

public class Result {
    private  int code;
    private  String msg;
    private  Object data;

    public Result(){}
    public Result(int code,String msg,Object data){
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result getSuccess(Object data){
        return new Result(200,"查询成功",data);
    }
    public static Result getFail( Object data){
        return new Result(201,"查询失败",data);
    }
    public static Result saveSuccess( Object data){
        return new Result(200,"添加成功",data);
    }
    public static Result saveFail( Object data){
        return new Result(201,"添加失败",data);
    }
    public static Result updateSuccess( Object data){
        return new Result(200,"修改成功",data);
    }
    public static Result updateFail( Object data){
        return new Result(201,"修改失败",data);
    }
    public static Result deleteSuccess( Object data){
        return new Result(200,"删除成功",data);
    }
    public static Result deleteFail( Object data){
        return new Result(201,"删除失败",data);
    }

    public  int getCode(){
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
    @Override
    public String toString(){
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
